package dao.mapper.auth;

import model.auth.Roles;
import model.auth.RolesAuthorities;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mybatis.spring.annotation.Mapper;

@Mapper("auth.RolesCrudMapper")
public interface RolesCrudMapper {

	@Select("select seq_a_roles.nextval from dual")
	long selectKey(); 
	
	@Insert(" insert into a_roles (id, rolename, roledesc, enabled, issys) values (#{m.id}, #{m.rolename}, #{m.roledesc}, #{m.enabled}, #{m.issys})")
	int insert(@Param("m") Roles model);
	
	@Select("select * from a_roles where id=#{id} ")
	RolesAuthorities getById(@Param("id") Long id);

	@Select("select * from a_roles where id=#{id} and enabled=#{enabled}")
	RolesAuthorities getValidById(@Param("id") Long id, @Param("enabled") Integer enabled);
	
	@Delete("delete from a_roles where id=#{id}")
	int deleteById(@Param("id") Long id);
}
